package de.karlNet.executor.io;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

public class AppReader {
	private List<String> apps = new LinkedList<String>();
	private HashMap<String, String> appHashMap = new HashMap<String, String>();

	public List<String> getApps() {
		return apps;
	}

	public HashMap<String, String> getAppHashMap() {
		return appHashMap;
	}

	private BufferedReader appReader;

	public AppReader() {
		try {
			this.appReader = new BufferedReader(new FileReader(
					"/Applications/installedApps"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public void readIn() {
		String readLine = null;
		try {
			while ((readLine = this.appReader.readLine()) != null) {
				String appName = readLine.split("=")[0];
				String path = readLine.split("=")[1];
				this.apps.add(appName);
				this.appHashMap.put(appName, path);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
